package com.egame.ewidget.observer;

import android.database.ContentObserver;
import android.os.Handler;
import android.util.Log;

/**
 * Class that extends {@link ContentObserver} in order to register change of
 * brightness settings.
 */
public class BrightnessContentObserver extends ContentObserver {

	private static final String TAG = BrightnessContentObserver.class
			.getSimpleName();

	/**
	 * Interface that defines call back method for notifying that observed
	 * parameter is was changed.
	 */
	public static interface BrightnessStateChangedListener {

		void brightnessStateChanged();
	}

	private BrightnessStateChangedListener mListener;

	public BrightnessContentObserver(Handler handler,
			BrightnessStateChangedListener listener) {
		super(handler);
		mListener = listener;
	}

	@Override
	public void onChange(boolean selfChange) {
		Log.d(TAG, "Called onChange");

		mListener.brightnessStateChanged();

		super.onChange(selfChange);
	}

}